package Operation;

import BookRack.BookRack;
import BookRack.Book;

public class FindBookOperation implements IOperation{

    private String searchKeyword;

    public void AuthorOrTitleSearch(String searchKeyword) {
        this.searchKeyword = searchKeyword;
    }

    @Override
    public void work(BookRack bookRack) {

        for (Book book : bookRack.getBooks()) {
            if (book.getAuthor().equals(searchKeyword) || book.getTitle().equals(searchKeyword)) {
                System.out.println("书名或作者名: " + book.getTitle()  + book.getAuthor());
            }
        }

    }
}
